package com.denlaku.longan.config;

import com.denlaku.longan.filter.TenantRequestFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author tianx
 */
@Configuration
public class CoreConfig {

    /**
     * 创建租户上下文Filter注册Bean
     *
     * @return Bean
     */
    @Bean
    public FilterRegistrationBean<TenantRequestFilter> cusTenantRequestFilter() {
        FilterRegistrationBean<TenantRequestFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new TenantRequestFilter());
        registration.addUrlPatterns("/api/*", "/page/*", "/image/resource/*");
        registration.setName("cusTenantRequestFilter");
        registration.setOrder(20);
        return registration;
    }
}
